﻿// zc.cpp: 实现文件
//

#include "pch.h"
#include "luntan.h"
#include "zc.h"
#include "afxdialogex.h"
#include"luntanDlg.h"
#include "zc0.h"



// zc 对话框

IMPLEMENT_DYNAMIC(zc, CDialogEx)

zc::zc(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_ZC, pParent)
	, m_username1(_T(""))
	, m_userpwd1(_T(""))
	, m_usernickname(_T(""))
{

}

zc::~zc()
{
}

void zc::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, m_username1);
	DDX_Text(pDX, IDC_EDIT2, m_userpwd1);
	DDX_Text(pDX, IDC_EDIT3, m_usernickname);
	DDX_Control(pDX, IDC_COMBO2, m_sex);
}


BEGIN_MESSAGE_MAP(zc, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON3, &zc::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON2, &zc::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON1, &zc::OnBnClickedButton1)
	ON_CBN_SELCHANGE(IDC_COMBO2, &zc::OnCbnSelchangeCombo2)

END_MESSAGE_MAP()


// zc 消息处理程序


void zc::OnBnClickedButton3()
{
	// TODO: 在此添加控件通知处理程序代码
	zc::OnOK();
	CluntanDlg a;
	a.DoModal();
}


void zc::OnBnClickedButton2()
{
	// TODO: 在此添加控件通知处理程序代码
	zc::OnOK();
	zc0 a;
	a.DoModal();
}


void zc::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	UpdateData(TRUE);
	if (m_username1 != "" && m_userpwd1 != "" && m_usernickname != "")
	{
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
	CString sql;
	sql.Format("insert into Users(user_Name,User_Pwd,User_nickname,User_sex) values('%s','%s','%s','%s')",m_username1,m_userpwd1,m_usernickname,sex);
	m_AdoConn.ExecuteSQL((_bstr_t)sql);
	MessageBox("注册成功！","注册结果");
	m_username1 = "", m_userpwd1 = "", m_usernickname = "";
	UpdateData(false);
	}
	else
	{
		MessageBox("注册信息不能为空！", "提示", MB_ICONWARNING);
	}
}


BOOL zc::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化
	m_sex.SetCurSel(0);
	m_sex.GetLBText(m_sex.GetCurSel(), sex);
	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}


void zc::OnCbnSelchangeCombo2()
{
	// TODO: 在此添加控件通知处理程序代码
	m_sex.GetLBText(m_sex.GetCurSel(), sex);
}



